#ifndef IMAGEPROVIE_H
#define IMAGEPROVIE_H
#include <QQuickImageProvider>
#include <QImage>
#include <QPainter>
#include <QColor>
#include <QImage>
#include <QDebug>
#include "imageloader.h"
class imageProvie:public QQuickImageProvider
{
public:
  //  imageProvie(): QQuickImageProvider(QQuickImageProvider::Pixmap){}
    imageProvie(): QQuickImageProvider(QQuickImageProvider::Image){}

private:
    QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize){
        int width = 160;
        int height = 100;

        if(size)
            *size = QSize(width,height);
        qDebug()<<id;
        if (id=="q") {
            return Imageloader::getInstance()->getImg(size);
            qDebug()<<"a;";
        }
        if (id=="pro") {
            return Imageloader::getInstance()->getImgPro();
            qDebug()<<"pro";
        }
        QImage pixmap(size->width(),size->height(),QImage::Format_ARGB32_Premultiplied);
        pixmap.fill(QColor("red").rgba());

        return pixmap;
    }

//    QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
//      {
//          int width = 160;
//          int height = 100;

//          if(size)
//              *size = QSize(width,height);

//          QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width,
//                         requestedSize.height() > 0 ? requestedSize.height() : height);
//          pixmap.fill(QColor("blue").rgba());
//          return pixmap;
//      }

};

#endif // IMAGEPROVIE_H



